<?php
namespace app\index\controller;



use think\Request;
use think\Db;

class News extends \think\Controller
{
    public function index()
    {

         

        // $s=input('param.');
      

       return view();
         
       

    }



    
    public function newslist()
    {
        //新闻分类
        $id['Level']=2;

        $info=Db::table('news_cate')->where($id)->select();

        $this->assign('info',$info); 


       // 获取顶级新闻分类

        $top_cate_list=Db::table('news_cate')->where("Level",1)->select();

        $this->assign('top_cate_list',$top_cate_list); 

        //查询内页分类
        $s=input('param.'); 

        $s['topid']= $s['topid'] ?  $s['topid']  : 1; 

        $c_news_cate=Db::table('news_cate')->where('ParentID',$s['topid'])->limit(7)->select();
        
        $this->assign('c_news_cate',$c_news_cate);
        
        $cateid=input('id');

        if(!empty($cateid)){
                    //列表页
               $where['InfoCategoryID']=input('id');

               $where['BusModelID']= $s['topid'];

               $list=Db::table('news')->where($where)->order('id desc')->paginate(10);

        }else{
                $where['BusModelID']= $s['topid'];

                $list=Db::table('news')->where($where)->order('id desc')->paginate(10);

        }

        $page = $list->render();

        $this->assign('list',$list);

       
        $this->assign('page', $page);
        
         //top 顶部图片3个
 
        $top['ISTop']=1;

        $top['InfoCategoryID']=input('id');

        $toplist=Db::table('news')->where($top)->limit(3)->select();

             //三农人物
        $cate['BusModelID']=5;

        $catelist=Db::table('news')->where($cate)->limit(3)->select();

        $this->assign('catelist',$catelist);   

         //热点导读
        $hot['BusModelID']=4;

        $hotlist=Db::table('news')->where($hot)->limit(3)->select();

        $this->assign('hotlist',$hotlist); 


        $this->assign('toplist',$toplist);

        return view(); 



    }

    public function news()
    {    

        $db= Db::table('news');

        $id['Level']=2;

        $info=Db::table('news_cate')->where($id)->limit(7)->select();

        $this->assign('info',$info);  

        $Level['Level']=1;

        $where=Db::table('news_cate')->where($Level)->select();

        $this->assign('where',$where);  
         
        $id=input('id');

        $news=Db::table('news')->find($id);
           
        $this->assign('t',$news);

        //阅读量
        Db::table('news')->where('ID',$id)->setInc('PageNum');

        $data=Db::table('news')->order('id desc')->limit(3)->select();

        $this->assign('data',$data);

        $list['BusModelID']=5;

        $res=Db::table('news')->where($list)->limit(3)->select();

        $this->assign('res',$res);

        //下一页
        $next=Db::table('news')->where("ID",">",$id)->order('id asc')->value('ID');
        $prev=Db::table('news')->where("ID","<",$id)->order('id desc')->value('ID');

        $this->assign("next_prev",array('next'=>$next,'prev'=>$prev));
        //上一页

     	return view(); 

    }




   public function soheinfo()
   {

    return view();
   }



    
    public function join()
    {
        return view();
    }





    public function contact()
    {

        return view();
    }





    
    public function pageindex()
    {
        return view();
    }

   
      
}
